//
//  GKZYPostBarImageShowViewController.m
//  GKZYAid
//
//  Created by lanou3g on 16/3/14.
//  Copyright © 2016年 GKZYAid. All rights reserved.
//

#import "GKZYPostBarImageShowViewController.h"

@interface GKZYPostBarImageShowViewController ()

@end

@implementation GKZYPostBarImageShowViewController

- (void)loadView
{
    self.postBarImageShowView = [[GKZYPostBarImageShowView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - 49)];
    self.view = self.postBarImageShowView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.postBarImageShowView.arrayAllImages = self.arrayAllImages;
    self.postBarImageShowView.index = self.index;
    self.postBarImageShowView.scrollViewImage.delegate = self;
    for (int i = 0; i < self.arrayAllImages.count - 1; i++) {
        ((UIScrollView *)[self.postBarImageShowView.scrollViewImage viewWithTag:101 + i]).delegate = self;
    }
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    for (UIScrollView *scV in scrollView.subviews) {
        if ([scV isKindOfClass:[UIScrollView class]]) {
            [scV setZoomScale:1.0];
            self.viewCurrent.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - 49);
        }
    }
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    self.viewCurrent = [scrollView subviews][0];
    return [scrollView subviews][0];
}

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale
{
    if (scrollView.zoomScale < 1) {
        self.viewCurrent.center = CGPointMake(self.postBarImageShowView.center.x, self.postBarImageShowView.center.y);
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
